package db;

import java.util.ArrayList;

public class Filter {
  ArrayList<String> filterList;

  public Filter() {
  	filterList = new ArrayList<String> ();
  }
  
  public void add(String name) {
    filterList.add(name);
  }

  public String toSQL() {
    String sql = "";
    boolean first = true;
    for (String filter : filterList) {
      if (first) {
        first = false;
        sql = "WHERE " + filter;
      } else {
        sql = sql + " AND " + filter;
      }
    }

    return sql;
  }
  
  public static void main(String[] args) {
  	Filter f = new Filter();
  	f.add("age > 10 AND age < 20");
  	f.add("quarter = quarter");
  	f.add("category = 1");
  	
  	System.out.println(f.toSQL());
  }
}
